home *** CD-ROM | disk | FTP | other *** search
/ Hacker's Secrets 4 / Hacker's Secrets 4.iso / faq / news1068.txt < prev    next >
Text File  |  1997-01-06  |  16KB  |  328 lines

  1. Subject: computer-security/compromise FAQ
  2. Supersedes: <secfaq.p2_850416605@iss.net>
  3. Date: 27 Dec 1996 18:12:14 GMT
  4.  
  5.  
  6. Posting-frequency: monthly
  7. Last-Modified: 1995/4/05
  8. Version: 2.0
  9.  
  10. Compromise FAQ
  11.  
  12. Version: 2.0
  13. ----------------------------------------------------------------------------
  14. This Security FAQ is a resource provided by:
  15.  
  16.      Internet Security Systems, Inc.
  17.      Suite 660, 41 Perimeter Center East          Tel: (770) 395-0150
  18.      Atlanta, Georgia 30346                       Fax: (770) 395-1972
  19.  
  20. ----------------------------------------------------------------------------
  21. To get the newest updates of Security files check the following services:
  22.  
  23.      http://www.iss.net/
  24.      ftp ftp.iss.net /pub/
  25.  
  26. ----------------------------------------------------------------------------
  27.  
  28. What if your Machines are Compromised by an Intruder.
  29.  
  30. This FAQ deals with some suggestions for securing your Unix machine after it
  31. has already been compromised. Even if your machines have not been
  32. compromised, there are many helpful tips on securing a machine in this
  33. paper.
  34.  
  35.   1. Try to trace/follow the intruder back to his origin via looking at
  36.  
  37.        1. who
  38.        2. w
  39.        3. last
  40.        4. lastcomm
  41.        5. netstat
  42.        6. snmpnetstat
  43.        7. router information.
  44.        8. /var/adm/messages (many crackers send e-mail to their "home"
  45.           accounts)
  46.        9. syslog (sends logs to other hosts as well)
  47.       10. wrapper logs
  48.       11. do a 'finger' to all local users(and check where they last logged
  49.           in from)
  50.       12. history files from shells, such as .history, .rchist, and similiar
  51.           files.
  52.  
  53.      Footnote: 'who', 'w', 'last', and 'lastcomm' are commands that rely on
  54.      /var/adm/pacct, /usr/adm/wtmp, and /etc/utmp to report the information
  55.      to you. Most backdoors will keep the intruder from being shown in these
  56.      logs. Even if the intruder has not installed any backdoors yet, it is
  57.      trivial to remove any detection in these logs. But they may just forget
  58.      about one or two of them. Especially if you have some additional,
  59.      non-standard ones.
  60.  
  61.      Suggestion: Install xinetd or tcp_wrapper that will log all connections
  62.      to your machine to see if someone is knocking on its doors. Forward
  63.      syslogs to another machine so intruder will not easily detect the logs
  64.      and modify. Other possibilities: netlog from
  65.      net.tamu.edu:/pub/security.
  66.  
  67.      It might be wise to monitor the intruder via some ethernet sniffer to
  68.      see how he is exploiting his systems before taking corrective measures.
  69.  
  70.   2. Close the machine from outside access. Remove from network to stop
  71.      further access via intruder. If the intruder finds out that the
  72.      administrator is unto him, he may try to hide his tracks by rm -rf /.
  73.  
  74.   3. Check the binaries with the originals. Especially check the following
  75.      binaries because they are commonly replaced backdoors for regaining
  76.      access:
  77.  
  78.        1. /bin/login
  79.        2. all the /usr/etc/in.* files (ie. in.telnetd)
  80.        3. and /lib/libc.so.* (on Suns).
  81.        4. anything called from inetd
  82.  
  83.      Other commonly replaced backdoor binaries:
  84.  
  85.        1. netstat - allows hiding connections
  86.        2. ps - allows hiding processes (ie Crack)
  87.        3. ls - allows hiding directories
  88.        4. ifconfig - hides the fact that promiscuity mode is on the ethernet
  89.        5. sum - fools the checksum for binaries, not necessarily replaced
  90.           anymore because its possible to change the checksum of the
  91.           binaries to the correct value without modifying sum. *EMPHASIZE*
  92.           Do NOT Rely on sum.
  93.  
  94.      Use 'ls -lac' to find the real modification time of files. Check
  95.      /etc/wtmp (if you still have one) for any system time adjustments.
  96.      Check the files with the distribution media (CD or tape) or calculate
  97.      MD5 checksums and compare them with the originals kept offline (you did
  98.      calculate them sometime ago, didn't you?) Suggestion: cmp the files
  99.      with copies that are known to be good.
  100.  
  101.      Another popular backdoor is suid'ing a common command (ie. /bin/time)
  102.      to allow root access with regular accounts.
  103.  
  104.      To find all suid programs you may use:
  105.  
  106.           find / -type f -perm -4000 -ls
  107.  
  108.      To be thorough you may need to re-load the entire OS to make sure there
  109.      are no backdoors. Tripwire helps prevent modifying binaries and system
  110.      files (ie. inetd.conf) on the system, without the administrator
  111.      knowing.
  112.  
  113.   4. Implement some password scheme for your users to verify that they
  114.      change their passwords often. Install anlpasswd, npasswd, or passwd+ in
  115.      place of passwd (or yppasswd) so that your users are forced to set
  116.      reasonable passwords. Then run Crack, which is available on
  117.      ftp.cert.org:/pub/tools/crack to make sure that your users aren't
  118.      bypassing the password check. Crack ensures that users are picking
  119.      difficult passwords. With the network, clear text passwords are a
  120.      problem. Other possible choices: smart hubs (stops ethernet sniffing of
  121.      the whole LAN) and one-time password technology.
  122.  
  123.   5. Check all the users' .rhosts and .forward files to make sure none of
  124.      them are weird or out of the ordinary. If .rhosts file contains '+ +',
  125.      the account can be accessed anywhere by anyone without a password. COPS
  126.      has a scripts for checking .rhosts.
  127.  
  128.           find / -name .rhosts -ls -o -name .forward -ls
  129.  
  130.      Look also for all the files created/modified in the time you are
  131.      suspecting the break-in has taken place, eg:
  132.  
  133.           find / -ctime -2 -ctime +1 -ls
  134.  
  135.      To find all the files modified not less than one day ago, but not more
  136.      than 2.
  137.  
  138.      All .login, .logout, .profile, .cshrc files are also worth looking at
  139.      (at least for the modification date/time). Make sure there are no
  140.      '.rhosts' for the locked or special accounts (like 'news', 'sundiag',
  141.      'sync', etc.) The shell for such accounts should be something like
  142.      '/bin/false' anyway (and not '/bin/sh') to make them more secure. Also
  143.      search for directories that have like ". ", ".. " as names. They are
  144.      usually found in /tmp , /var/tmp, /usr/spool/* and any other publicly
  145.      writeable directory.
  146.  
  147.   6. Check to make sure your NFS exports are not world writable to everyone.
  148.      NFSwatch available on harbor.ecn.purdue.edu:/pub/davy , a program by
  149.      David Curry, will log any NFS transactions that are taking place. Try
  150.      'showmount -e' to see whether system agrees with your opinion of what
  151.      are you exporting and where. There are bugs in some nfsd
  152.      implementations which ignore the access lists when they exceed some
  153.      limit (256 bytes). Check also what are you IMPORTING!!! Use 'nosuid'
  154.      flag whenever possible. You do not want to be cracked by a sysadm from
  155.      another host (or a cracker there) running suid programs mounted via
  156.      NFS, do you?
  157.  
  158.   7. Make sure you have implemented the newest sendmail daemon. Old sendmail
  159.      daemons allowed remote execution of commands on any Unix machine. See
  160.      the computer-security/security-patch FAQ.
  161.  
  162.   8. Try to install all the security patches available from the vendor on
  163.      your machine. See the computer-security/security-patch FAQ.
  164.  
  165.   9. Here is a check list of common ways that a machine is vulnerable:
  166.  
  167.        1. Do an rpcinfo -p on your machine to make sure it is not running
  168.           any processes that are not needed. (ie. rexd).
  169.  
  170.        2. Check for '+' in /etc/hosts.equiv.
  171.  
  172.        3. Check whether tftp is disabled on your system. If not - disable
  173.           it, or at least use '-s' flag to chroot it to some safe area, if
  174.           you really can't live without it (it is mostly used for booting up
  175.           Xterminals, but sometimes can be avoided by NFS-mounting
  176.           appropriate disks). Under no circumstances you should run it as
  177.           root. Change the line describing it in /etc/inetd.conf to
  178.           something like:
  179.  
  180.                tftp dgram udp wait nobody /usr/etc/in.tftpd in.tftpd -s
  181.                /tftpboot
  182.  
  183.           or better yet, use tcpd wrapper program to protect it from
  184.           addresses which should not get access to tftp and log all other
  185.           connections:
  186.  
  187.                tftp dgram udp wait nobody /usr/etc/tcpd in.tftpd -s
  188.                /tftpboot
  189.  
  190.           and edit appropriately /etc/hosts.allow to restrict access to
  191.           in.tftpd to only those addresses that really need it.
  192.  
  193.        4. Check crontabs and at-jobs. Make sure there are no delayed bombs
  194.           which will explode after you think you have got rid of all the
  195.           nasty things left by a intruder.
  196.  
  197.        5. Check /etc/rc.boot /etc/rc.local (SYSV: /etc/rc?.d/* ) and other
  198.           files cruicial for the system startup. (The best would be if you
  199.           could compare them with the copies kept off-line). Check all other
  200.           files containing system configuration (sendmail.cf, sendmail.fc,
  201.           hosts.allow, at.allow, at.deny, cron.allow, hosts, hosts.lpd,
  202.           etc.) In 'aliases' look for aliases expanding to some unusual
  203.           programs (uudecode is one but example).
  204.  
  205.        6. Check your inetd.conf and /etc/services files to find if there are
  206.           no additional services set up by an intruder.
  207.  
  208.        7. Copy all the log files you still have (pacct, wtmp, lastlog,
  209.           sulog, syslog, authlog, any additional logs you have set up
  210.           earlier) to some safe place (offline) so you may examine them
  211.           later. Otherwise, do not be surprised if they disappear the next
  212.           day when the cracker realises he forgot to remove one of them. Use
  213.           your own imagination to find what other traces he could have left
  214.           in your system (What about /tmp/* files? Check them BEFORE you
  215.           reboot).
  216.  
  217.        8. Make backup copy of /etc/passwd (best offline) then change all
  218.           root passwords (after verifying that 'su' and 'passwd' are not the
  219.           trojan versions left by an intruder). It may sound like a horrible
  220.           thing to do (especially if you have something like 2000 users) but
  221.           *do* lock them all by putting '*' in the password field. If the
  222.           intruder has a copy of your passwords file he may possibly sooner
  223.           or later guess all the passwords contained there (It is all the
  224.           matter of proper dictionaries). In fact he could have inserted few
  225.           passwords that he only knows for some users who for example have
  226.           not logged in for a long time.
  227.  
  228.           On the NIS servers check not only the real /etc/passwd /etc/groups
  229.           etc files but also those used for building NIS maps (if they are
  230.           different).
  231.  
  232.        9. Check if your anonymous ftp (and other services) are configured
  233.           properly (if you have any of course) See the
  234.           computer-security/anonymous-ftp FAQ.
  235.  
  236.       10. If you want to make your life easier next time (or if you still
  237.           cannot get rid of an intruder) consider installing 'ident' daemon.
  238.           Together with tcpd on a set of hosts it can be used to find what
  239.           accounts the intruder is using.
  240.  
  241.       11. Make sure the only 'secure' terminal is console (if at all). This
  242.           way you prevent root logins just from the net. Maybe it is not a
  243.           big deal as if somebody knows the root password he may already
  244.           know other peoples' passwords too, but maybe not?
  245.  
  246.       12. Check hosts.equiv, .rhosts, and hosts.lpd for having # as comments
  247.           within those files. If an intruder changes his hostname to #, it
  248.           will be considered a trusted host and allow him to access your
  249.           machines.
  250.  
  251.       13. And remember... There are so many ways that somebody could have
  252.           modified your system, that you really have to have your eyes and
  253.           ears wide open for a loooooong long time. Above, are the pointers
  254.           just to the most obvious things to check.
  255.  
  256.  10. Mail all the sites that you were able to find out that the intruder was
  257.      going through and warn them. Also, CC: cert@cert.org. Check all the
  258.      sites in your near-by, ie. in your domain/institution/whatever. It's
  259.      usually trivial for a hacker to get to another system by a simple
  260.      'rlogin' if the two systems have a common subset of users (and using
  261.      .rhosts to make the access easier).
  262.  
  263.  11. A preventive from stopping many intruders from even trying your network
  264.      is to install a firewall.
  265.  
  266.      Side-effects: Firewalls may be expensive; filtering may slow down the
  267.      network. Consider blocking nfs (port 2049/udp) and portmap(111/udp) on
  268.      your router. The authentication and access controls of these protocols
  269.      is often minimal. Suggestion: Block all udp ports except DNS and NTP
  270.      ports. Kill all source routing packets. Kill all ip-forwarding packets.
  271.  
  272. Acknowledgements
  273.  
  274. Thanks to the following people for adding and shaping this FAQ:
  275.  
  276. Tomasz Surmacz <tsurmacz@asic.ict.pwr.wroc.pl>
  277. Wes Morgan (morgan@engr.uky.edu)
  278. Alan Hannan (alan@noc1.mid.net)
  279. Peter Van Epp <vanepp@sfu.ca>
  280. Richard Jones <electron@suburbia.apana.org.au>
  281. Wieste Venema <wietse@wzv.win.tue.nl>
  282. Adrian Rodriguez <adrian@caip.rutgers.edu>
  283. Jill Bowyer <jbowyer@selma.hq.af.mil>
  284. Andy Mell <amell@cup.cam.ac.uk>
  285.  
  286. ----------------------------------------------------------------------------
  287.  
  288. Copyright
  289.  
  290. This paper is Copyright (c) 1994, 1995, 1996
  291.    by Christopher Klaus of Internet Security Systems, Inc.
  292.  
  293. Permission is hereby granted to give away free copies electronically. You
  294. may distribute, transfer, or spread this paper electronically. You may not
  295. pretend that you wrote it. This copyright notice must be maintained in any
  296. copy made. If you wish to reprint the whole or any part of this paper in any
  297. other medium excluding electronic medium, please ask the author for
  298. permission.
  299.  
  300. Disclaimer
  301.  
  302. The information within this paper may change without notice. Use of this
  303. information constitutes acceptance for use in an AS IS condition. There are
  304. NO warranties with regard to this information. In no event shall the author
  305. be liable for any damages whatsoever arising out of or in connection with
  306. the use or spread of this information. Any use of this information is at the
  307. user's own risk.
  308.  
  309. Address of Author
  310.  
  311. Please send suggestions, updates, and comments to:
  312. Christopher Klaus <cklaus@iss.net> of Internet Security Systems, Inc.
  313. <iss@iss.net>
  314.  
  315. Internet Security Systems, Inc.
  316.  
  317. ISS is the leader in network security tools and technology through
  318. innovative audit, correction, and monitoring software. The Atlanta-based
  319. company's flagship product, Internet Scanner, is the leading commercial
  320. attack simulation and security audit tool. The Internet Scanner SAFEsuite is
  321. based upon ISS' award-winning Internet Scanner and was specifically designed
  322. with expanded capabilities to assess a variety of network security issues
  323. confronting web sites, firewalls, servers and workstations. The Internet
  324. Scanner SAFEsuite is the most comprehensive security assessment tool
  325. available. For more information about ISS or its products, contact the
  326. company at (770) 395-0150 or e-mail at iss@iss.net. ISS maintains a Home
  327. Page on the World Wide Web at http://www.iss.net
  328.